package com.google.code.p.fop_qrcode;

import java.util.HashMap;

import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FONode;
import org.w3c.dom.DOMImplementation;

public class QRCodeElementMapping extends ElementMapping {
    public final static String NAMESPACE = "http://code.google.com/p/fop-qrcode";
    
    public QRCodeElementMapping() {
        this.namespaceURI = NAMESPACE;
        initialize();
    }

    /** @see org.apache.fop.fo.ElementMapping#getDOMImplementation() */
    public DOMImplementation getDOMImplementation() {
        return getDefaultDOMImplementation();
    }

    /** @see org.apache.fop.fo.ElementMapping#initialize() */
    @Override
    @SuppressWarnings("unchecked")
    protected void initialize() {
        if (foObjs == null) {
            foObjs = new HashMap();
            foObjs.put("qrcode", new QRCodeRootMaker());
            foObjs.put(DEFAULT, new QRCodeMaker());
        }
    }

    static class QRCodeMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new QRCodeObj(parent);
        }
    }

    static class QRCodeRootMaker extends ElementMapping.Maker {
        public FONode make(FONode parent) {
            return new QRCodeElement(parent);
        }
    }

}
